﻿Jxstar.currentPage = function() {
	var config = {param:{},initpage:function(page, define){},eventcfg:{}};

	var auditData = Jxstar.findComboData('audit');
	var paytypeData = Jxstar.findComboData('paytype');
	var authtypeData = Jxstar.findComboData('authtype');
	var htstatusData = Jxstar.findComboData('htstatus');
	var httypeData = Jxstar.findComboData('httype');
	var moneytypeData = Jxstar.findComboData('moneytype');
	var purtypeData = Jxstar.findComboData('purtype');

	var cols = [
	{col:{header:'实施单位ID', width:100, sortable:true, hidden:true}, field:{name:'contract__dept_id',type:'string'}},
	{col:{header:'主键', width:100, sortable:true, hidden:true}, field:{name:'contract__contract_id',type:'string'}},
	{col:{header:'项目ID', width:100, sortable:true, hidden:true}, field:{name:'contract__project_id',type:'string'}},
	{col:{header:'项目负责人ID', width:100, sortable:true, hidden:true}, field:{name:'contract__project_userid',type:'string'}},
	{col:{header:'记录状态', width:84, sortable:true, hidden:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: auditData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: auditData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < auditData.length; i++) {
				if (auditData[i][0] == value)
					return auditData[i][1];
			}
		}}, field:{name:'contract__audit_up',type:'string'}},
	{col:{header:'合同编号', width:100, sortable:true}, field:{name:'contract__contract_code',type:'string'}},
	{col:{header:'项目负责人', width:100, sortable:true, hidden:true}, field:{name:'contract__project_user',type:'string'}},
	{col:{header:'合同名称', width:177, sortable:true}, field:{name:'contract__contract_name',type:'string'}},
	{col:{header:'合同金额(万元)', width:109, sortable:true, align:'right',renderer:JxUtil.formatNumber(6)}, field:{name:'contract__contract_money',type:'float'}},
	{col:{header:'甲方单位', width:152, sortable:true, hidden:true}, field:{name:'contract__company_dept',type:'string'}},
	{col:{header:'合同签订部门', width:158, sortable:true}, field:{name:'contract__done_deptname',type:'string'}},
	{col:{header:'甲方经办人', width:76, sortable:true}, field:{name:'contract__company_user',type:'string'}},
	{col:{header:'乙方单位', width:176, sortable:true}, field:{name:'contract__provider_name',type:'string'}},
	{col:{header:'乙方经办人', width:84, sortable:true}, field:{name:'contract__provider_user',type:'string'}},
	{col:{header:'合同签订日期', width:100, sortable:true, align:'center',
		renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'contract__write_date',type:'date'}},
	{col:{header:'付款方式', width:100, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: paytypeData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: paytypeData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < paytypeData.length; i++) {
				if (paytypeData[i][0] == value)
					return paytypeData[i][1];
			}
		}}, field:{name:'contract__settle_type',type:'string'}},
	{col:{header:'开户银行', width:100, sortable:true, hidden:true}, field:{name:'contract__bank_name',type:'string'}},
	{col:{header:'银行账号', width:143, sortable:true, hidden:true}, field:{name:'contract__bank_account',type:'string'}},
	{col:{header:'质保期(月)', width:100, sortable:true, align:'right',renderer:JxUtil.formatInt()}, field:{name:'contract__quality_month',type:'int'}},
	{col:{header:'实施单位', width:149, sortable:true}, field:{name:'contract__dept_name',type:'string'}},
	{col:{header:'项目编号', width:100, sortable:true}, field:{name:'contract__project_code',type:'string'}},
	{col:{header:'要求完工日期', width:100, sortable:true, hidden:true, align:'center',
		renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'contract__finish_date',type:'date'}},
	{col:{header:'验收日期', width:100, sortable:true, hidden:true, align:'center',
		renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'contract__check_date',type:'date'}},
	{col:{header:'项目名称', width:206, sortable:true}, field:{name:'contract__project_name',type:'string'}},
	{col:{header:'授权形式', width:100, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: authtypeData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: authtypeData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < authtypeData.length; i++) {
				if (authtypeData[i][0] == value)
					return authtypeData[i][1];
			}
		}}, field:{name:'contract__auth_type',type:'string'}},
	{col:{header:'合同有效期', width:100, sortable:true, hidden:true, align:'center',
		renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'contract__contract_date',type:'date'}},
	{col:{header:'合同送审日期', width:100, sortable:true, hidden:true, align:'center',
		renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'contract__send_date',type:'date'}},
	{col:{header:'费用及计算', width:100, sortable:true, hidden:true}, field:{name:'contract__cost',type:'string'}},
	{col:{header:'工作概述', width:100, sortable:true, hidden:true}, field:{name:'contract__work_profile',type:'string'}},
	{col:{header:'条款审查', width:100, sortable:true, hidden:true}, field:{name:'contract__article_check',type:'string'}},
	{col:{header:'备注', width:100, sortable:true, hidden:true}, field:{name:'contract__memo',type:'string'}},
	{col:{header:'合同创建日期', width:100, sortable:true, hidden:true, align:'center',
		renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'contract__creat_date',type:'date'}},
	{col:{header:'合同状态', width:100, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: htstatusData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: htstatusData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < htstatusData.length; i++) {
				if (htstatusData[i][0] == value)
					return htstatusData[i][1];
			}
		}}, field:{name:'contract__contract_status',type:'string'}},
	{col:{header:'供应商ID', width:100, sortable:true, hidden:true}, field:{name:'contract__provider_id',type:'string'}},
	{col:{header:'审计通过日期', width:100, sortable:true, hidden:true, align:'center',
		renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'contract__pass_date',type:'date'}},
	{col:{header:'已付款金额(万元)', width:100, sortable:true, align:'right',renderer:JxUtil.formatNumber(6)}, field:{name:'contract__pay_money',type:'float'}},
	{col:{header:'项目批复金额(万元)', width:100, sortable:true, align:'right',renderer:JxUtil.formatNumber(6)}, field:{name:'contract__project_money',type:'float'}},
	{col:{header:'合同签订部门ID', width:100, sortable:true, hidden:true}, field:{name:'contract__done_deptid',type:'string'}},
	{col:{header:'合同类型', width:100, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: httypeData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: httypeData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < httypeData.length; i++) {
				if (httypeData[i][0] == value)
					return httypeData[i][1];
			}
		}}, field:{name:'contract__contract_type',type:'string'}},
	{col:{header:'项目类别', width:100, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: moneytypeData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: moneytypeData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < moneytypeData.length; i++) {
				if (moneytypeData[i][0] == value)
					return moneytypeData[i][1];
			}
		}}, field:{name:'contract__money_type',type:'string'}},
	{col:{header:'账面欠款金额(万元)', width:100, sortable:true, align:'right',renderer:JxUtil.formatNumber(2)}, field:{name:'contract__last_money',type:'float'}},
	{col:{header:'支付进度%', width:100, sortable:true, align:'right',renderer:JxUtil.formatNumber(2)}, field:{name:'contract__pay_ratio',type:'float'}},
	{col:{header:'合同编制人', width:100, sortable:true, hidden:true}, field:{name:'contract__create_user',type:'string'}},
	{col:{header:'记录状态', width:100, sortable:true, hidden:true}, field:{name:'contract__auditing',type:'string'}},
	{col:{header:'谈判单号', width:100, sortable:true, hidden:true}, field:{name:'contract__say_code',type:'string'}},
	{col:{header:'累积工程量变更金额(万元)', width:100, sortable:true, hidden:true, align:'right',renderer:JxUtil.formatNumber(2)}, field:{name:'contract__money_allchg',type:'float'}},
	{col:{header:'决算审定金额(万元)', width:100, sortable:true, hidden:true, align:'right',renderer:JxUtil.formatNumber(6)}, field:{name:'contract__cost_money',type:'float'}},
	{col:{header:'合同文本', width:100, sortable:true, hidden:true}, field:{name:'contract__contract_file',type:'string'}},
	{col:{header:'合同付款条件', width:100, sortable:true, hidden:true}, field:{name:'contract__contract_condition',type:'string'}},
	{col:{header:'采购方式', width:100, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: purtypeData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: purtypeData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < purtypeData.length; i++) {
				if (purtypeData[i][0] == value)
					return purtypeData[i][1];
			}
		}}, field:{name:'contract__pur_type',type:'string'}},
	{col:{header:'父合同编码', width:100, sortable:true}, field:{name:'contract__contract_parentcode',type:'string'}}
	];
	
	config.param = {
		cols: cols,
		sorts: null,
		hasQuery: '1',
		isedit: '0',
		isshow: '1',
		funid: 'contract_query'
	};
	
	
	config.initpage = function(gridNode) {		//点击“已完成”按钮，更改合同状态		var grid = gridNode.page;		var event = gridNode.event;		event.on('beforecustom', function(ge) {			var records = ge.grid.getSelectionModel().getSelections();			if (!JxUtil.selectone(records)) return false;					var contract_status = records[0].get('contract__contract_status');			if (contract_status != '3') {				JxHint.alert('选择的合同不是已生效状态，不能完成！');					return false;			}		});			}
		
	return new Jxstar.GridNode(config);
}